package com.etc.admin.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.etc.admin.service.RoomService;
import com.etc.entity.Room;
import com.etc.util.CommonMessage;
import com.etc.util.PageData;
/**
 * 
 * @author 蒋丽娟
 *
 */

@Controller
public class RoomController {
	@Resource(name="roomService")
private RoomService rs;
	/**
	 * 房间展示，分页
	 * @param page
	 * @param limit
	 * @param content
	 * @return
	 */
	@RequestMapping(value="RoomPage")
	@ResponseBody
	public PageData<Room> roomByPage(Integer page,Integer limit,String content){
		if(content==null)
	    content="";
		PageData<Room> pd=rs.getRoomByPage(page, limit, content);
		pd.setCode(0);
		pd.setMsg("ok");
		return pd;
	}
	
	@RequestMapping(value="editRoom")
	@ResponseBody
	public CommonMessage editRoom(int roomno,int roomsalary){
		System.out.println(roomno+","+roomsalary);
		CommonMessage cm=new CommonMessage();
		Room room=rs.selectRoomByNo(roomno);
		int roomtype=room.getRoomtype();
		boolean flag=rs.upsalaryByRoomtype(roomtype, roomsalary)>0;
		if(flag) {
			cm.setMsg("修改成功");
			}else {
		cm.setMsg("修改失败");}
			return cm;
	}
	
}
